import java.util.Stack;

public class T {
}


class Solution {
    public int evalRPN(String[] tokens) {

        Stack<Integer> stack=new Stack<>();
        for (int i = 0; i <tokens.length ; i++) {
            String n=tokens[i];
            int j=0;
            int k=0;

            switch (n){

                case "+":
                   j=stack.pop();
                   k=stack.pop();

                    stack.push(k+j);
                    break;
                case "-":
                     j=stack.pop();
                    k=stack.pop();


                    stack.push(k-j);


                    break;
                case "*":
                     j=stack.pop();
                    k=stack.pop();


                    stack.push(k*j);


                    break;

                case "/":
                    j=stack.pop();
                    k=stack.pop();


                    stack.push(k/j);


                    break;
                default:
                    stack.push(Integer.parseInt(n));

                    break;
            }



        }
        return stack.peek();

    }
}